package fosu.generated.service.impl;

import fosu.generated.service.DetectionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * AI检测服务实现类
 */
@Service
public class DetectionServiceImpl implements DetectionService {

    private static final Logger logger = LoggerFactory.getLogger(DetectionServiceImpl.class);

    @Override
    public double detectAIProbability(String text) {
        logger.debug("检测文本，长度: {}", text.length());

        // 模拟AI检测，返回0-100的随机概率
        // 实际应该调用真实的AI检测API
        double probability = Math.random() * 100;

        logger.debug("检测完成，AI概率: {}%", probability);
        return probability;
    }

    @Override
    public String rewriteParagraph(String originalText, double aiProbability) {
        logger.debug("改写段落，原文长度: {}, AI概率: {}%", originalText.length(), aiProbability);

        // 模拟改写后的文本
        // 实际应该调用大语言模型API进行改写
        String rewritten = "【智能改写后的文本】" + originalText + "\n[改写提示：已降低AI生成特征]";

        logger.debug("改写完成，新文本长度: {}", rewritten.length());
        return rewritten;
    }
}